<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='BUI'>/**
</span> * @fileOverview 画布内部的元素扩展
 * @ignore
 */
  
var BUI = require(&#39;bui-common&#39;);

<span id='BUI-Graphic-CanvasItem'>/**
</span> * @class BUI.Graphic.CanvasItem
 * 画布内部元素的一些公用方法的扩展，仅作为接口使用
 */
var Item = function(){

};

BUI.augment(Item,{
<span id='BUI-Graphic-CanvasItem-method-toFront'>  /**
</span>   * 到达最高层次 z-index
   */
  toFront : function(){
    this.get(&#39;el&#39;).toFront();
    return this;
  },
  toBack : function(){
    this.get(&#39;el&#39;).toBack();
    return this;
  },
<span id='BUI-Graphic-CanvasItem-method-translate'>  /**
</span>   * 移动
   * @param  {Number} dx 沿x轴平移的距离
   * @param  {Number} dy 沿y轴平移的距离
   */
  translate : function(dx,dy){
    var _self = this,
      el = _self.get(&#39;el&#39;);
    el.translate(dx,dy);
    return this;
  },
  index : function(){
    var _self = this,
      parent = _self.get(&#39;parent&#39;);
    return BUI.Array.indexOf(_self,parent.get(&#39;children&#39;));
  },
<span id='BUI-Graphic-CanvasItem-method-animate'>  /**
</span>   * 执行动画
   * @param  {Object}   params   动画的参数
   * @param  {Number}   ms       毫秒数
   * @param  {String}   easing   路径函数
   * @param  {Function} callback 回调函数
   */
  animate : function(params,ms,easing,callback){
    this.get(&#39;el&#39;).animate(params,ms,easing,callback);
    return this;
  },
<span id='BUI-Graphic-CanvasItem-method-stopAnimate'>  /**
</span>   * 停止当前动画
   */
  stopAnimate : function(){
    this.get(&#39;el&#39;).stop();
    return this;
  },
<span id='BUI-Graphic-CanvasItem-method-drag'>  /**
</span>   * 拖动方法
   */
  drag : function(onmove, onstart, onend, mcontext, scontext, econtext){
    this.get(&#39;el&#39;).drag(onmove, onstart, onend, mcontext, scontext, econtext)
    return this;
  }
});

module.exports = Item;
</pre>
</body>
</html>
